﻿#include <iostream>
#include <fstream>
#include <string>
#include <map>

std::map<std::string, std::string> config;

bool loadConfig(const std::string& filename) {
    std::ifstream file(filename);
    if (!file) return false;

    std::string line;
    while (std::getline(file, line)) {
        if (line.empty() || line[0] == '#') continue;

        size_t pos = line.find('=');
        if (pos != std::string::npos) {
            std::string key = line.substr(0, pos);
            std::string value = line.substr(pos + 1);
            config[key] = value;
        }
    }
    return true;
}

int main() {
    if (!loadConfig("bsl.conf")) {
        std::cout << "配置文件加载失败!" << std::endl;
        return 1;
    }

    // 直接使用配置
    std::cout << "端口: " << config["PORT"] << std::endl;
    std::cout << "波特率: " << config["BAUDRATE"] << std::endl;

    return 0;
}